package com.zxc.wordcount;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class WcDriver {
    public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        //1 获取job对象
        final Job job = Job.getInstance(conf);
        //2 设置jar存储位置
        job.setJarByClass(WcDriver.class);
        //3关联map和reduce
        job.setMapperClass(WcMapper.class);
        job.setReducerClass(WcReducer.class);
        //4设置mapper阶段k v 类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(IntWritable.class);
        //5设置最终输出的 k y 类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(IntWritable.class);
        //6设置输入路径输出路径
        FileInputFormat.setInputPaths(job,new Path(args[0]));
        FileOutputFormat.setOutputPath(job,new Path(args[1]));

        job.submit();
    }
}
